<template>
<view class="exchange">
  <!-- 自定义标题栏 -->
  <navigation-bar :title="'兑换' + member" extClass="nav" id="top"></navigation-bar>
  <view class="container">
    <div class="inputBox">
      <input v-model="cdkey" type="text" placeholder="请输入您的兑换码" placeholder-class="inputPlaceholder">
    </div>
    <div class="bindUserBox" v-if="bindUser" @tap.stop="showTips">
      <text class="bindUser">已绑定代理：白萝卜白白</text>
    </div>
    <div class="butBox">
      <div class="but" @tap.stop="getVip">立即兑换</div>
    </div>
    <div class="tipsBox">
      <div class="title">兑换规则</div>
        <p class="content">1. 兑换码可以用来兑换【开单虾】{{member}}权限；</p>
        <p class="content">2. 兑换码是有N个字符组成，输入后即可兑换相应{{member}}权限；</p>
        <p class="content">3. 兑换码只能使用一次，兑换后立即失效；</p>
        <p class="content">4. 请谨慎保存兑换码，如忘记或遗失平台不予负责；</p>
        <p class="content">5. 兑换码是【开单虾】上海旭冉信息科技有限公司提供给{{member}}体验不同权限的体验码，任何人或单位不得通过销售、转卖兑换码获利，一经发现，将追究相应责任；</p>
        <p class="content">6. 上海旭冉信息科技有限公司保留最终解释权。</p>
    </div>
  </view>
  <popup-tips ref="popupTips" title="代理商资料" content=""></popup-tips>
</view>
</template>

<script>
let App = getApp().globalData;
import navigationBar from '@/components/navigationBar/index';
import popupTips from '@/components/popup-tips/index';

export default {
  data() {
    return {
      bindUser: false,
      member: App.member,
      list: [],
	  cdkey: ''
    };
  },

  components: {
    'navigation-bar': navigationBar,
    popupTips
  },
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },
  methods: {
		getVip() {
			uni.showLoading()
			App._post_form('vip.collection/exchangeCdkey', {
				cdkey: this.cdkey
			}, (result) => {
				uni.hideLoading()
        this.$api.msg(result.msg)
				if (result.code == '1') {
					// this.$emit('showTips', i + 1 + '')
				}
			}, () => {
				uni.hideLoading()
			})
    },
    showTips() {
      this.$refs.popupTips.open()
    }
  }
};
</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>